package com.neusoft.po;




//PO和BO放在一起，未单独使用BO
public class VirtualWallet {
	private Integer walletId;
	private String userId;//钱包对应所属用户
	private String createTime;
	private Double balance;
	

	//充值
//	@Transactional
//	public int recharge(Integer walletId, String userId, Double addAmount) {
//		//1.创建交易流水PO
//		VirtualWalletTransaction transaction = new VirtualWalletTransaction();
//		//交易流水持久化
//		//注：自己的持久化不算业务逻辑，交给service类完成；自己以外的对象算业务逻辑一部分，封装在BO中
//		transaction.setTime(CommonUtil.getCurrentDate());
//		transaction.setAmount(addAmount);
//		transaction.setTransactionType(1);
//		transaction.setInWalletId(walletId);
//		//充值无出账钱包
//		transactionMapper.saveTransaction(transaction);
//		
//		//2.改变虚拟钱包金额
//		//注，为了实现方便，把virtualWallet的持久化也封装在这里了
//		int result=0;
//		result = virtualWalletMapper.addBalanceByUserId(walletId, userId, addAmount);
//		return result;
//	}
//	
//		//支付
//		@Transactional
//		public int payment(Integer walletId, String userId, Double paymentAmount) {
//			int transactionId=0;
//			//1.创建交易流水
//			//创建PO
//			VirtualWalletTransaction transaction = new VirtualWalletTransaction();
//			//交易流水持久化
//			//注：自己的持久化不算业务逻辑，交给service类完成；自己以外的对象算业务逻辑一部分，封装在BO中
//			transaction.setTime(CommonUtil.getCurrentDate());
//			transaction.setAmount(paymentAmount);
//			transaction.setTransactionType(3);
//			//transaction.setInWalletId(inId);
//			//支付没有入账钱包
//			transaction.setOutWalletId(walletId);
//			//transactionId = transactionMapper.saveTransaction(transaction);
//			
//			//2.改变虚拟钱包金额
//			//注，为了实现方便，把virtualWallet的持久化也封装在这里了
//			//virtualWalletMapper.minusBalanceByUserId(walletId, userId, paymentAmount);
//			return transactionId;
//		}
	
	
	//支持方法
	public void addBalance(Double addAmount) {
		this.balance+=addAmount;
	}
	
	//getter,setter
	public Integer getWalletId() {
		return walletId;
	}
	public void setWalletId(Integer walletId) {
		this.walletId = walletId;
	}
	public String getUserId() {
		return userId;
	}
	public void setUserId(String userId) {
		this.userId = userId;
	}
	public String getCreateTime() {
		return createTime;
	}
	public void setCreateTime(String createTime) {
		this.createTime = createTime;
	}
	public Double getBalance() {
		return balance;
	}
	public void setBalance(Double balance) {
		this.balance = balance;
	}
	
	
	
}
